package Test1;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;

import Test1.GeneralFunction.*;
import Test1.ACS.*;
import Test1.PTZ.GetPreSetName;
import Test1.PTZ.PTZAbsoluteEX;
import Test1.Thermometry.*;
import com.sun.jna.NativeLong;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;

/**
 * 
 */

public class Test1 {

	static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
	public static int lUserID = -1;//用户句柄
	static int dwState = -1; //人员信息状态
	static int dwFaceState = -1; //下发人脸数据状态
	static int iCharEncodeType = 0;//设备字符集

	/**
	 * @param args
	 * @throws UnsupportedEncodingException 
	 * @throws InterruptedException 
	 * @throws JSONException
	 */
	public static void main(String[] args) throws UnsupportedEncodingException, InterruptedException, JSONException  {

		/*初始SDK*/
		hCNetSDK.NET_DVR_Init();
		hCNetSDK.NET_DVR_SetLogToFile(3, "C:/JavaDemoLog", true);
		//TODO 库加载代码 设置异常消息回调 报警分离

		/*登陆*/
		Login login = new Login();
		lUserID = login.getlUserID("172.16.1.211",(short)8000,"admin","a12345678");

		/*
		 * 该结构体中的坐标值与当前预览显示框的大小有关，现假设预览显示框为352*288,我们规定原点为预览显示框左上角的顶点，前四个参数计算方法如下:
		 * xTop=鼠标当前所选区域的起始点坐标的值*255/352;
		 * xBottom =鼠标当前所选区域的结束点坐标的值*255/352;
		 * yTop=鼠标当前所选区域的起始点坐标的值*255/288;
		 * yBottom=鼠标当前所选区域的结束点坐标的值*255/288;
		 * 缩小条件:×Top减去xBottom的值大于2。放大条件:xTop小于xBottom.
		 *
		 * desc: 屏幕左下角为坐标原点
		 */

		// 3d ptz 功能
//		hCNetSDK.NET_DVR_GetDeviceConfig(lUserID,HCNetSDK.NET_DVR_GET_MULTI_STREAM_COMPRESSIONCFG,1);
		HCNetSDK.NET_DVR_POINT_FRAME point_frame = new HCNetSDK.NET_DVR_POINT_FRAME();
		point_frame.xTop = 185;
		point_frame.xBottom = 23;

		point_frame.yTop = 101;
		point_frame.yBottom = 175;

		point_frame.bCounter = 1;

//		boolean b = hCNetSDK.NET_DVR_PTZSelZoomIn(lUserID, point_frame);
		boolean b = hCNetSDK.NET_DVR_PTZSelZoomIn_EX(lUserID,1, point_frame);
		int i = hCNetSDK.NET_DVR_GetLastError();
		System.out.println(i);
		System.out.println(b);

		//获取门禁人员能力集
		//GetACSAbility getACSability = new GetACSAbility();
		//getACSability.getACSAbility(lUserID);

		/*测试语音对讲*/
//		VoiceTalk voiceTalk = new VoiceTalk();
//		voiceTalk.StartVoiceTalk(lUserID,1,true);
//		voiceTalk.StartVoiceTalk(lUserID,1,true);

		/*按时间下载文件*/
	//	GetFileByTime getFileByTime = new GetFileByTime();
	//	getFileByTime.getFileByTime(lUserID, "E://pic//video.mp4",1,2021,3,25,11,44,2,2021,3,25,11,44,12);

		/*获取高精度PTZ绝对位置配置*/
//		PTZAbsoluteEX getPTZAbsoluteEX = new PTZAbsoluteEX();
//		getPTZAbsoluteEX.ptzAbsoluteEX(lUserID,1);

		/*设备抓图*/
//		CaptureJPEGPicture captureJPEGPicture = new CaptureJPEGPicture();
//		captureJPEGPicture.captureJPEGPicture(lUserID,1,(short)9);

		/*获取预置点名称配置*/
//		GetPreSetName getPreSetName = new GetPreSetName();
//		getPreSetName.getPreSetName(lUserID,new NativeLong(1),(short)3);

		/*测温补光灯点亮*/
		//LightPTZControlWithSpeed lightPTZControlWithSpeed = new LightPTZControlWithSpeed();
		//lightPTZControlWithSpeed.lightPTZControlWithSpeed(lUserID,1,2,1,2);

       /*测试测温基本参数配置和获取*/
//		BasicParam basicParam = new BasicParam();
//		basicParam.basicParam(lUserID,2);

        /*测专家测温获取及配置*/
//       SetROI setROI = new SetROI();
//       setROI.setROI(lUserID,2);

		/*测试手动获取测温规则温度信息*/
//		ThreadGetOnceTempData threadGetOnceTempData = new ThreadGetOnceTempData();
//		threadGetOnceTempData.threadGetOnceTempData(lUserID, new NativeLong(1));

		/*测试实时获取测温规则温度信息*/
//		RealtimeThermometry realtimeThermometry = new RealtimeThermometry();
//		realtimeThermometry.realtimeThermometry(lUserID,2,(byte)0,(byte)1,(short)1);
//		while (true)
//		{
//
//		}

		/*测试设备抓图附加全屏测温数据*/
//		JpegWithAppendData jpegWithAppendData = new JpegWithAppendData();
//		jpegWithAppendData.jpegWithAppendData(lUserID, 2);
//
		/*测试全屏测温*/
//		P2PRealData p2PRealData = new P2PRealData();
//		p2PRealData.getData(lUserID,2);

		/*测试获取专家测温配置参数*/
//		ThermometryPresetInfo thermometryPresetInfo = new ThermometryPresetInfo();
//		thermometryPresetInfo.thermometryPresetInfo(lUserID,2);
//
		/**报警布防**/
//		Alarm alarm = new Alarm();
//		alarm.SetupAlarmChan(lUserID,-1);
		/** 登出 **/
		if(hCNetSDK.NET_DVR_Logout(lUserID)){
			System.out.println("登出成功！！！");
		}
	}
	 
}//Test1  Class结束
